﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="keywords" content="房产销冠, 房地产,卡考网络" />
    <meta name="description" content="上海卡考网络有限公司" />
    <title>房产销冠</title>
    <link rel="stylesheet" href="css/global.css" type="text/css" />
    <link rel="stylesheet" href="css/form.css" type="text/css" />
    <link rel="stylesheet" href="css/default.css" />
    <link href="bootstrap/iCheck-master/skins/minimal/orange.css" rel="stylesheet" type="text/css" />
   <!-- <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css" type="text/css" />-->
    <link rel="stylesheet" href="css/gri.controls.css" type="text/css" />
    <link rel="stylesheet" href="css/bootstrap-switch.css" type="text/css" />

    <script src="http://dn-blqw.qbox.me/jq+bs+art.js" type="text/javascript"></script>
    <script src="js/jquery-form.js" type="text/javascript"></script>
    <script src="js/underscore.js" type="text/javascript"></script>
    <script src="js/jquery-my-Extension.js" type="text/javascript"></script>
    <!--<script src="js/bootstrap-switch.min.js" type="text/javascript"></script>-->
    <script src="js/kk.js" type="text/javascript"></script>
    <!--<script type="text/javascript" src="bootstrap/js/bootstrap.min.js"></script>-->
    <!--<script type="text/javascript" src="bootstrap/iCheck-master/icheck.js"></script>-->
    <script type="text/javascript" src="js/WdatePicker.js"></script>
    <script type="text/javascript" src="js/dateRange.js"></script>
    <script type="text/javascript" src="js/formValidator.js"></script>
       <!--图片上传-->
    <link href="Scripts/webuploader/webuploader.css" rel="stylesheet" />
    <script src="Scripts/webuploader/webuploader.min.js" type="text/javascript"></script>
    <script src="Scripts/webuploader/webupload.expand.js" type="text/javascript"></script>
    <script type="text/javascript">
            $(function () {
                //单图上传
                $("#btnUpLoadL").powerWebUpload({
                    onComplete: function (data) {
                        //alert(JSON.stringify(data));
                        $('#imgBuilding').attr('src', "http://" + window.location.host + data.filePath);
                        $("#picUrl").val(data.filePath);
                    },
                    PostbackHold: false
                });

                //多图上传
                var imgUrl = $("#productPic").val();
                $("#btnUpLoadList").powerWebUpload({
                    onComplete: function (data) {
                        var str = "<div class=\"frompic1 fl\"><div><img src=\"http://" + window.location.host + data.filePath + "\"  width=\"105\" height=\"77\"  /></div><div class=\"picdetline\"><img src=\"images/from_picclose.png\" />删除</div>";
                        $("#imgList").append(str);

                        if (imgUrl != "" || imgUrl != null) {
                            alert(imgUrl);
                            imgUrl += "|";
                        }
                        imgUrl += data.filePath;
                        $("#productPic").val(imgUrl);

                    },
                    PostbackHold: true
                    , ShowDownload: true
                });

            });

    </script>
    <!--<script charset="utf-8" src="js/kindeditor-min.js"></script>-->
    <!--<script charset="utf-8" src="js/zh_CN.js"></script>-->
    <script type="text/javascript">
        $(document).ready(function () {
            initInput();
        });

        function initInput() {
            $('.lab112 :checkbox').iCheck({
                checkboxClass: 'icheckbox_minimal-orange',
                radioClass: 'iradio_minimal-orange',
                increaseArea: '20%' // optional
            });
            $('.lab112 :radio').iCheck({
                checkboxClass: 'icheckbox_minimal-orange',
                radioClass: 'iradio_minimal-orange',
                increaseArea: '20%' // optional
            });
        }
    </script>
</head>
<body style="background: #f1f1f1;">
    <div class="main01 pb50">
        <div class="fromtit1 clearfix">
            <h1 class="ff">商品管理》添加实物</h1>
            <a href="#" class="gouback">返回</a>
        </div>
        <div class="fromtit2 clearfix">
            <h2 class="ff">展示信息</h2>
        </div>
        <div class="frommod clearfix">
            <form id="form1" action="">
                 <input type="hidden" id="kid" name="kid" value="0"/>
                <table border="0" cellspacing="0" cellpadding="0" class="fromtab1">
                    <tr>
                        <th>商品分类：&nbsp;</th>
                        <td>
                            <select id="F_CateogryKid" class="selall sel100 fl" style="margin-right: 11px;">
                                <option>--商品分类--</option>
                            </select>
                            <input type="hidden" id="categoryKid" name="categoryKid"  value="0" />
                        </td>
                    </tr>
                    <tr>
                        <th>商品名称：&nbsp;</th>
                        <td>
                            <input type="text" id="productName" name="productName" value="" class="inpall inp435" placeholder="请填写商品标题" maxlength="16" validateType="*notempty"/>
                        </td>
                    </tr>
                   <!-- <tr>
                        <th>说明文字：&nbsp;</th>
                        <td>
                            <input type="text" class="inpall inp435" placeholder="请填写商品在列表的附加说明" maxlength="32" />
                        </td>
                    </tr>-->
                    <tr>
                        <th>详细说明：&nbsp;</th>
                        <td>
                            <textarea  id="description" name="description" rows="" cols="" class="textall02 text435" placeholder="请输入详细说明" validateType="notempty"></textarea>
                        </td>
                    </tr>
                    <tr>
                        <th>商品缩略图：&nbsp;</th>
                        <td>
                            <div class="clearfix">
                                <div class="frompic1 fl" id="">
                                    <div>
                                        <img id="imgBuilding" src="images/build_pics.jpg" width="105" height="77" />
                                    </div>
                                    <div class="picdetline">
                                        <img src="images/from_picclose.png" />
                                        删除
                                    </div>
                                </div>
                                <div class="fl">
                                    <div class="picinfos"id="btnUpLoadL">(请上传200px*150px的图片 )</div>
                                    <input type="hidden" id="picUrl" name="picUrl" value=""/>
                                    <!--<a href="#" class="picbtn">选择图片</a>-->
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <th>商品详情图：&nbsp;</th>
                        <td>
                            <div class="clearfix">
                                <div class="frompic1 fl">
                                    <div>
                                        <img src="images/build_pics.jpg" />
                                    </div>
                                    <div class="picdetline">
                                        <img src="images/from_picclose.png" />
                                        删除
                                    </div>
                                </div>
                                <div class="fl">
                                    <div class="picinfos" id="btnUpLoadList">(请上传200px*150px的图片 )</div>
                                    <input type="hidden" id="productPic" name="productPic" value=""/>
                                   <!-- <a href="#"  class="picbtn">选择图片</a>-->
                                </div>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <th>需要积分：&nbsp;</th>
                        <td>
                            <input type="text" id="pointNum" name="pointNum" value="" class="inpall inp435" placeholder="请输入消耗积分" validateType="*number"/>
                        </td>
                    </tr>
                    <tr>
                        <th>库存剩余：&nbsp;</th>
                        <td>
                            <input type="text" id="inventoryNum" name="inventoryNum" value="" class="inpall inp435" placeholder="请输入库存数" validateType="*number"/>
                        </td>
                    </tr>
                    <tr>
                        <th>日期：&nbsp;</th>
                        <td>
                            <div class="date" id="div_date">
                                <span class="date_title" id="date">2014-12-16 至 2014-12-22</span>
                                <input type="hidden" id="beginTime" name="beginTime" value="2014-12-16" />
                                <input type="hidden" id="endTime" name="endTime" value="2014-12-22" />
                                <a class="opt_sel" id="input_trigger" href="#">
                                    <i class="i_orderd"></i>
                                </a>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <th>用户兑换次数：&nbsp;</th>
                        <td>
                            <input type="text" id="userExchangeNum" name="userExchangeNum" class="inpall inp329 fl" placeholder="请填写兑换次数" validateType="number"  validateOffset="0,105" />
                            <div class="fromsex fl">
                                <a href="javascript:;" class="sex_1 on" onclick="SexSelect1()">永久</a><a href="javascript:;" class="sex_2" onclick="SexSelect2()">每天</a>
                                <input type="hidden" class="sex_inp" name="exchangeType" value="0" />
                            </div>

                        </td>
                    </tr>
                    <tr>
                        <th>&nbsp;</th>
                        <td>
                            <label class="lab112"><input type="radio" name="isSelect" value="0" checked/>&nbsp;&nbsp;自动处理</label>
                            <label class="lab112"><input type="radio" name="isSelect" value="1" />&nbsp;&nbsp;手动处理</label>
                            <input type="hidden" id="status" name="status" value="0"/>
                        </td>
                    </tr>
                    <tr>
                        <th>开启兑换限制：&nbsp;</th>
                        <td style="width:120px;">
                            <div class="make-switch " data-switch-get="state" data-on-label="开启" data-off-label="关闭">
                                <input type="checkbox" class="isExchange" checked/>
                                <input type="hidden" id="isExchange" name="isExchange"/>
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <th>每日限兑数量：&nbsp;</th>
                        <td>
                            <input type="text" id="exchangeNum" name="exchangeNum" value="" class="inpall inp435" placeholder="请输入库存数" validateType="number"  />
                        </td>
                    </tr>
                    <tr>
                        <th>每日限兑时间：&nbsp;</th>
                        <td>
                            <input type="text"  id="beginHour"  class="inpall inp80 fl" maxlength="2" placeholder="09" />
                            <span class="inpword fl">时</span>
                            <input type="text"  id="beginMinute"  class="inpall inp80 fl" maxlength="2"placeholder="00" />
                            <span class="inpword fl">分</span>
                            <input type="hidden" id="exchangeBeginTime" name="exchangeBeginTime"/>
                            <div class="fl">至</div>
                            <input type="text"  id="endHour"  class="inpall inp80 fl" maxlength="2" placeholder="17" />
                            <span class="inpword fl">时</span>
                            <input type="text"  id="endMinute"  class="inpall inp80 fl" maxlength="2" placeholder="00" />
                            <span class="inpword fl">分</span>
                            <input type="hidden" id="exchangeEndTime" name="exchangeEndTime"/>
                        </td>
                    </tr>
                    <tr>
                        <th>&nbsp;</th>
                        <td>
                            <div class="sinput">
                                <input type="button" class="Save" value="加入仓库" onclick="f_AddWarehouse()" />
                                <input type="button" class="Cancel" value="立即上架" onclick="f_ImmediatelyOn()" />
                            </div>
                        </td>
                    </tr>
                </table>
            </form>
        </div>
    </div>

    <script type="text/javascript">
        var dateRange = new pickerDateRange('date', {
            startDate: '2010-12-10', // startDate 开始时间
            endDate: '2011-01-12', // endDate 结束时间
            theme: 'ta',
            target: 'asdfasdf', // target 日期选择框摆放的位置, 一般是在 form 中
            success: function (obj) {
                //alert($("#date").val());
                var selectDate = $("#date").val();
                $("#beginTime").val(selectDate.split(' 至 ')[0]);
                $("#endTime").val(selectDate.split(' 至 ')[1]);
            }
        });

        $(function () {
            f_GetProductCategoryList();
        });

        //获取商品分类
        function f_GetProductCategoryList() {
            $.getJSON("http://192.168.1.85:1060/ProductsCategory/GetList", function (res) {
                //alert(JSON.stringify(data))
                if (res.Code != 0 && res.Data.length > 0) {
                    return;
                }
                $.each(res.Data, function (i, obj) {
                    $("#F_CateogryKid").append("<option value='" + obj.Kid + "'>" + obj.F_CategoryName + "</option>");
                });
            });
        }

        $('#F_CateogryKid').change(function () {
            var CateogryKid = $(this).children('option:selected').val();
            $("#categoryKid").val(CateogryKid);
        });


        //提交保存及验证
        $(".inpall").blur(function () {
            validate($(this));
        })
        $(document).ready(function () {
            validateInit("");
        });

        $('.make-switch').on('switch-change', function (e, data) {
            if (!data.value) {
                $("#exchangeNum").parents("tr").hide();
                $("#beginHour").parents("tr").hide();
            } else {
                $("#exchangeNum").parents("tr").show();
                $("#beginHour").parents("tr").show();
            }
        });

        //立即上架
        function f_ImmediatelyOn() {
            f_SubmitSave();
            $.post("http://192.168.1.85:1060/PointProduct/ImmediatelyOn", $("#form1 :input[value],textarea").serializeArray(), function (res) {
                var obj = eval('(' + res + ')');
                alert(JSON.stringify(obj));
                if (obj.Code != "0") {
                    return $kk.alert(obj.Message, "提示");
                }
                return $kk.alert("上架成功");
            });
        }
        //加入仓库
        function f_AddWarehouse() {
            f_SubmitSave();
            $.post("http://192.168.1.85:1060/PointProduct/AddWarehouse", $("#form1 :input[value],textarea").serializeArray(), function (res) {
                var obj = eval('(' + res + ')');
                alert(JSON.stringify(obj));
                if (obj.Code != "0") {
                    return $kk.alert(obj.Message, "提示");
                }
                return $kk.alert("入库成功");
            });
        }

        function f_SubmitSave() {
            //表单验证
            if (!$("#form1").form("validate")) {
                return false;
            }
            alert(JSON.stringify($("#form1 :input[value],textarea").serializeArray()));
            if ($("input[name='isSelect']").eq(0).prop("checked")) {
                $("#status").val("0");
            } else {
                $("status").val("1");
            }

            ////单张图片必传判断
            //if ($("#picUrl").val() == null || $("#picUrl").val() == "") {
            //    return 

            //}
            ////多张图片判断
            //if ($("#picUrl").val() == null || $("#picUrl").val() == "") {
            //    return

            //}

            //时间判断
            var bHour = $("#beginHour").val();
            var eHour = $("#endHour").val();
            function isHour(num) {
                if (!isNaN(num) && num > 23 && num >= 0 && num.length != 2) {
                    return $kk.alert("请重新输入两位小时数(如15)", "提示");
                }
            }
            isHour(bHour);
            isHour(eHour);
            var bMinute = $("#beginMinute").val();
            var eMinute = $("#endMinute").val();
            function isMinute(num) {
                if (!isNaN(num) && num > 59 && num >= 0 && num.length != 2) {
                    return $kk.alert("请重新输入两位分钟数(如30)", "提示");
                }
            }
            isMinute(bMinute);
            isMinute(eMinute);

            $("#exchangeBeginTime").val(bHour + ":" + bMinute);
            $("#exchangeEndTime").val(eHour + ":" + eMinute);

            //是否开启
            if ($(".isExchange").prop("checked")) {
                $("#isExchange").val("1");
            } else {
                $("#isExchange").val("0");
            }

            //$("#form1").form("submit", {
            //    url: "http://192.168.1.175:1000/PointProduct/Save",
            //    //data: $("#form1 :input[value],textarea").serializeArray(),
            //    onSubmit: function () {
            //        return;
            //    },
            //    success: function (res) {
            //        var obj = eval('(' + res + ')');
            //        if (obj.Code != "0") {
            //            return $kk.alert(obj.Message, "提示");
            //        }
            //        return $kk.alert("提交成功", "提示");
            //    }
            //});
            ////alert(JSON.stringify($("#form1").form("getData")));
        }

    </script>
    <script type="text/javascript">
        function SexSelect1() {
            $(".sex_1").addClass("on");
            $(".sex_2").removeClass("on");
            $(".sex_inp").val(0);

        }
        function SexSelect2() {
            $(".sex_2").addClass("on");
            $(".sex_1").removeClass("on");
            $(".sex_inp").val(1);
        }
    </script>
</body>
</html>